<template>
        <el-card shadow="never" style="max-height: 700px; overflow: auto">
            <el-form ref="form" :model="form" :rules="rules" label-width="90px" :disabled="disabled">
                <el-form-item label="id:" prop="id" v-show="false">
                    <el-input v-model="form.id" disabled />
                </el-form-item>
                <el-form-item label="admin_ids:" prop="admin_ids" v-show="false">
                    <el-input v-model="form.admin_ids" disabled />
                </el-form-item>
                <el-form-item label="新归属人" prop="attributor">
                    <SelectPage v-model="form.attributor" :url="'/admin/system.admin/selectPage'" show_field="nickname" placeholder="请选择站点" query_field="nickname" :multiple="false" />
                </el-form-item>
                <el-form-item label="变更备注:" prop="remarks">
                    <el-input v-model="form.remarks" placeholder="" clearable />
                </el-form-item>
                <el-form-item label="变更时间:" prop="createtime">
                    <el-date-picker
                        v-model="form.createtime"
                        align="right"
                        type="datetime"
                        placeholder="选择日期"
                        >
                    </el-date-picker>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" @click="submitForm">确认 </el-button>
                    <!-- <el-button type="warning" @click="cancel">取消 </el-button> -->
                </el-form-item>
            </el-form>
        </el-card>
</template>

<script>
export default {
    name: 'editattrForm',
    props: {
        findFormData: {
            type: Object,
            default: {}
        },
        editFormParams: {
            type: Object,
            default: {}
        },
        // 表单是否禁用
        disabled: {
            type: Boolean,
            default: false,
        },
        
    },
    data() {
        return {
            // 编辑表单验证规则
            rules: {
                title: [{ required: true, message: "请输入平台", trigger: "blur" }],
                // account: [{ required: true, message: "请输入账号组", trigger: "blur" }],
                siteid: [{ required: true, message: "请输入域名", trigger: "blur" }],
        
            },
            form: {
                account: [
                    {
                        value: '',
                    },
                    {
                        value: '',
                    },
                    {
                        value: '',
                    },
                ],
            },
        }
    },
    watch: {
        findFormData: {
            handler(nval) {
                if (JSON.stringify(nval) != '{}') {
                    this.$nextTick(() => {
                        this.form = nval
                    })
                }
            },
            immediate: true,
            deep: false,
        },
        
    },
    methods: {
        removeAccount(item) {
            var index = this.form.account.indexOf(item)
            if (index !== -1) {
            this.form.account.splice(index, 1)
            }
        },
        addAccount() {
            this.form.account.push({
            value: '',
            // key: Date.now()
            });
        },
        // 取消按钮
        cancel() {
            this.$emit('editFormCancel')
        },

        submitForm() {
            this.$refs['form'].validate((valid, obj) => {
                if (valid) {
                    this.form.createtime = Date.parse(this.form.createtime);
                    this.$emit('submitForm', this.form)
                }
            })
        },

        // 表单重置
        reset() {
            this.resetForm('form')
        }
    }
}
</script>
